﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Streaming_Service.User {
    public class UserFunc {
        public static bool IsUser(UserSession session) {
            return session != null && session.UserId > 0 && session.Token.Length == 32;
        }

        public static bool IsUser(UserSession provided, UserSession verified) {
            if (provided == null || verified == null) return false;
            return IsUser(provided) && IsUser(verified) && provided.UserId == verified.UserId && provided.Token == verified.Token;
        }

        public static bool IsAdmin(UserSession session) {
            return IsUser(session) && session.IsAdmin;
        }

        public static bool IsAdmin(UserSession provided, UserSession verified) {
            return IsAdmin(provided) && IsAdmin(verified) && provided.UserId == verified.UserId && provided.Token == verified.Token;
        }
    }
}